package com.smart.fourteen.hibernate.base.dao;

import com.smart.fourteen.hibernate.base.model.Topic;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional()  //子类使用注解，需要在父类BaseDao上也加上@Transactional注解
public class TopicDao extends BaseDao<Topic>{
    public void delete(int id){
        Topic topic = new Topic();
        topic.setId(1);
        delete(topic);
    }

    public long getTopicNum(){
        Object obj = getHibernateTemplate().iterate("select count(t.id) from Topic t").next();
        return (Long) obj;
    }
}
